from datetime import datetime

from pydantic import BaseModel, Field

from forward.extend.pydantic.base import BaseSchema
from forward.model.schemas.lucky.code_batch import CodeBatchSchema
from forward.utils.tools import ToolsUtil


class CodeBatchDetailOutSchema(CodeBatchSchema):
    id: int
    put_in_num: int | None = Field(None, description="已放入数量")
    unused_num: int | None = Field(None, description="未使用数量")
    status_text: str | None = Field(None, description="状态")
    code_encoding: str | None = Field(None, description="编码")
    created_time: datetime | None = Field(None, description="创建时间")
    bind_activity_count: int | None = Field(None, description="参与活动次数")


class CodeBatchAddInSchema(CodeBatchSchema):
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class CodeBatchEditInSchema(CodeBatchSchema):
    """
    编辑码批次
    """

    id: int


class CodeBatchListInSchema(BaseSchema):
    """
    列表查询参数
    """

    page_num: int = 1
    page_size: int = 20
    model_config = {
        "alias_generator": ToolsUtil.to_lower_camel,
        "populate_by_name": True,
    }


class CodeBatchDetailInSchema(BaseModel):
    """
    查询详情参数
    """

    id: int


class CodeBatchDeleteInSchema(BaseModel):
    """
    删除
    """

    id: int


class GenerateInSchema(BaseModel):

    count: int


class CodeBatchStatusInSchema(BaseModel):
    id: int
    status: int


class CodeBatchGenerateInSchema(BaseModel):
    id: int


class CodeBatchExportInSchema(BaseModel):
    id: int
